/**
 * 
 */
package com.changil.nowonchangilchurch.page;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;

import com.astuetz.PagerSlidingTabStrip;
import com.changil.nowonchangilchurch.R;
import com.changil.nowonchangilchurch.ui.item.Header;

/**
 * @author zeropol2
 * 
 */
public abstract class BaseActivity extends FragmentActivity {

	protected Header mHeader = null;
	protected PagerSlidingTabStrip mTabs = null;
	protected ViewPager mPager = null;
	protected FragmentPagerAdapter mAdapter = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_base);
		createLayout();
		initLayout();
		defineAdapter();
		setTabs();
	}
	
	private void createLayout() {
		mHeader = (Header)findViewById(R.id.activity_base_header);
		mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
		mPager = (ViewPager) findViewById(R.id.pager);
	}
	
	protected abstract void initLayout();
	protected abstract void defineAdapter();
	protected void setTabs() {
		mPager.setAdapter(mAdapter);
		mPager.setOffscreenPageLimit(mAdapter.getCount());
		final int pageMargin = getResources().getDimensionPixelSize(R.dimen.dp4);
		mPager.setPageMargin(pageMargin);
		mTabs.setViewPager(mPager);
		mTabs.setTextSize(getResources().getDimensionPixelSize(R.dimen.dp15));
	}
}
